/* -*- C++ -*- */
/*===========================================================
 
	.---=||||[ B L O O D Y ]|||||=====================----------....
	|                                                              |
	|    THE  M O S T   B L O O D Y  GAME EVER!                    |
	|                                                              |
	|    bloody harvest is coming... soon,                         |
	|                                              heil Satan!     |
	!                                                              !
	.                                                              ,
  ~~~~-------------================================|||||||||==-~




	Name-Space: {core, logic, editor}
	Module: {draw, coll, scgr, ...}
	Class: <name of class>
	Last modification:  <author>, <time>

	TODO:
	<-------- todo #1 ---------->
	<-------- todo #2 ---------->
	<-------- todo #3 ---------->
	............
	<-------- todo #n ---------->

	FIX:
	<-------- fix #1 ----------->
	<-------- fix #1 ----------->
	..........
	<-------- fix #n ----------->




 
 
	============================================================*/
#ifndef __draw_Light_Header_File__
#define __draw_Light_Header_File__

#include "common.h"
#include "core/vmath.h"
#include "core/Config.h"

namespace core
{
	namespace draw
	{

		/**
		 * Class presenting OpenGL light
		 */
		class Light
		{
				/**
				 * Position of light source
				 */
				Vector3f	position;

				/**
				 * Ambient color
				 */
				Vector4f	ambient;

				/**
				 * Diffuse color
				 */
				Vector4f	diffuse;

				/**
				 * Specular color
				 */
				Vector4f	specular;

				/**
				 * Attenuation factors in order
				 * x-quadratic, y-linear, z-constant
				 */
				Vector3f	attenuation;

				/**
				 * Light number (starting by 0).
				 */
				u32 lightNo;

				/**
				 * Is enabled?
				 */
				bool enabled;
			public:

				/**
				 * Creates new OpenGL light
				 */
				Light(u32 aLightNo = 0);

				/**
				 * Frees light
				 */
				virtual ~Light();

				/**
				 * Gets light source position.
				 */
				Vector3f	getPosition(){ return position; }

				/**
				 * Gets ambient color
				 */
				Vector4f	getAmbient(){ return ambient; }

				/**
				 * Gets diffuse color
				 */
				Vector4f	getDiffuse(){ return diffuse; }

				/**
				 * Gets specular color
				 */
				Vector4f	getSpecular(){ return specular; }

				/**
				 * Gets attenuation factors in order
				 * x-quadratic, y-linear, z-constant
				 */
				Vector3f	getAttenuation(){ return attenuation; }

				/**
				 * Sets light source position.
				 */
				void	setPosition(Vector3f value){ position = value; }

				/**
				 * Sets ambient color
				 */
				void	setAmbient(Vector4f value){ ambient = value; }

				/**
				 * Sets diffuse color
				 */
				void	setDiffuse(Vector4f value){ diffuse = value; }
				/**
				 * Sets specular color
				 */
				void	setSpecular(Vector4f value){ specular = value; }

				/**
				 * Sets attenuation factors in order
				 * x-quadratic, y-linear, z-constant
				 */
				void	setAttenuation(Vector3f value){ attenuation = value; }


				/**
				 * Sets light nubmer.
				 */
				void setLightNo(u32 aLightNo) { lightNo = aLightNo; }

				/**
				 * Gets light number.
				 */
				u32 getLightNo(){ return lightNo; }

				void enable(){ enabled = true; }
				void disable(){ enabled = false; }
				bool isEnabled(){ return enabled; }

				/**
				 * Upload Light settings to OpenGL device
				 */
				void bind();

				/**
				 * Clear after light.
				 */
				void unbind();

				static Light* fromConfig(const Config& cfg);
			

		};

	}
}

#endif  //__draw_Light_Header_File__
